﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using SqlMiM.Common;


namespace SqlMiM.SqlIndexes.UnusedIndexes
{
    public class Plugin : IPlugin
    {
        #region IPlugin Members

        private View view;
        private ViewModel viewModel;
        private ImageSource icon;
        private IPluginGroup group;


        public IPluginGroup Group
        {
            get { return group; }
        }

        public Guid Identity
        {
            get { throw new NotImplementedException(); }
        }

        public string Name
        {
            get
            {
                return "Unused Indexes";
            }
        }

        public string Description
        {
            get
            {
                return "Most unused indexes";
            }
        }

        public int Index
        {
            get
            {
                return 1;
            }
        }

        public UserControl Display
        {
            get
            {
                if (view == null) throw new ApplicationException("plugin view display is null");

                return view;
            }
        }




        public System.Windows.Input.Key Key
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public System.Windows.Media.ImageSource Icon
        {
            get
            {
                return this.icon;
            }
        }


        public Plugin(IPluginGroup group)
        {
            this.group = group;
            this.icon = new BitmapImage(new Uri("/SqlMiM.SqlIndexes;component/Images/database_gear.png", UriKind.Relative)); ;

        }

        public void Activate()
        {
            this.view = new View();
            this.viewModel = new ViewModel();
            this.view.DataContext = this.viewModel;
        }
        public void Refresh()
        {
            this.viewModel.Load();
        }

        public void Deactivate()
        {
            this.view = null;
            this.viewModel = null;

        }


        #endregion





    }
}
